package study.translation.utils;

import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

public class StringUtils
{
    public static String join( Collection c )
    {
        return join( c, "" );
    }

    public static String join( Collection c, String delimiter )
    {
        if( c.isEmpty() )
        {
            return "";
        }
        Iterator i = c.iterator();
        StringBuffer result = new StringBuffer().append( i.next() );
        while( i.hasNext() )
        {
            result.append( delimiter ).append( i.next() );
        }
        return result.toString();
    }

    public static String join( Object[] c )
    {
        return join( Arrays.asList( c ) );
    }

    public static String join( Object[] c, String delimiter )
    {
        return join( Arrays.asList( c ), delimiter );
    }
}
